package com.twu.biblioteca;

public class Item {
    protected String name;
    protected int Id;
    private int numberOfCopies;
    private int availableCopies;

    public Item(String title, int Id) {
        this.name =title;
        this.Id = Id;
        this.numberOfCopies = 1;
        this.availableCopies=1;
    }



    public String getName(){
        return name;
    }

    public boolean setChecked(){

        if(availableCopies>0) {
            this.availableCopies--;
            return true;
        }
        return false;
    }

    public  boolean  resetChecked(){
        if(availableCopies<numberOfCopies) {
            this.availableCopies++;
            return true;
        }
        return false;
    }

    public int getNumberOfAvailableCopies() {
        return this.availableCopies;
    }

    public int getId() {
        return Id;
    }

    @Override
    public String toString() {
        return "Item{" +
                "name='" + name + '\'' +
                ", Id=" + Id +
                ", numberOfCopies=" + numberOfCopies +
                '}';
    }
}
